<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let arr = [1,2,3,4,5]
    // 法1
     try{
        arr.map((item) => {
            if(item == 2) {
               throw('123')
            }
            console.log(item);
        })
     }
     catch(e) {
        console.log(e);
     }
    // 法2
    arr.map((item) => {
            if(item == 2) {
               break
            }
            console.log(item);
        })
    </script>
</body>
</html>